package org.lzfto.flink.demo.system.websocket;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

/**
 * socket服务，但暂时用不着
 */
@Service
public class WebSocketService {

    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    /**
     * 发送消息到指定用户
     * @param userId 用户ID
     * @param destination 目标地址
     * @param payload 消息内容
     */
    public void sendToUser(String userId, String destination, Object payload) {
        messagingTemplate.convertAndSendToUser(userId, destination, payload);
    }

    /**
     * 广播消息给所有订阅特定主题的客户端
     * @param destination 目标地址
     * @param payload 消息内容
     */
    public void broadcast(String destination, Object payload) {
        messagingTemplate.convertAndSend(destination, payload);
    }
}
